package com.xjj.service.controller;

import com.xjj.entity.AdviceCatogery;
import com.xjj.entity.ResponseEntity;
import com.xjj.service.service.AdviceCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description 通知类别
 * @Author zhangjin
 * @Date 2022/10/20 11:48
 */
@RestController
@RequestMapping("/advice")
public class AdviceCatogeryController {
    @Autowired
    private AdviceCategoryService categoryService;

    /**
     * 添加类别
     * @param catogery
     * @return
     */
    @PostMapping("/catogery/add")
    public ResponseEntity addCatogery(@RequestBody AdviceCatogery catogery){
        categoryService.addCatogery(catogery);
        return ResponseEntity.SUCCESS("添加成功",null);
    }

    /**
     * 修改通知类别
     * @param catogery
     * @return
     */
    @PostMapping("/catogery/update")
    public ResponseEntity updateCatogery(@RequestBody AdviceCatogery catogery){
        categoryService.updateCatogery(catogery);
        return ResponseEntity.SUCCESS("修改成功",null);
    }

    /**
     * 查询类别
     * @return
     */
    @GetMapping("/catogery/get")
    public ResponseEntity getCatogery(){
        return ResponseEntity.SUCCESS("查询成功",categoryService.getCatogeryList());
    }

    /**
     * 删除类别
     * @param adviceCatogery
     * @return
     */
    @PostMapping("/catogery/del")
    public ResponseEntity delCatogery(@RequestBody AdviceCatogery adviceCatogery){
        categoryService.delCatogery(adviceCatogery.getId());
        return ResponseEntity.SUCCESS("删除成功",null);
    }
}
